/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vx;

import java.util.HashMap;
import java.util.Iterator;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

/**
 *
 * @author mani
 */
class LoadSavedPartner {

    private HashMap<String, Integer> nn;

    LoadSavedPartner(String udir) throws DocumentException {
        nn = new HashMap<String, Integer>();
        SAXReader e = new SAXReader();
        Document doc = e.read(udir + "savedata.xml");
        Element root = doc.getRootElement();
        Iterator it = root.elementIterator();

        while (it.hasNext()) {
            Element node = (Element) it.next();
            String[] sa = new String[6];
            sa[0] = node.attribute("yahoo").getValue();
            sa[1] = node.attribute("BasicTrain").getValue();
            sa[2] = node.attribute("Logic").getValue();
            sa[3] = node.attribute("f1").getValue();
            sa[4] = node.attribute("f2").getValue();
            sa[5] = node.attribute("f3").getValue();
            String join = StringUtils.join(sa, ":");
            nn.put(join, new Integer(0));

        }
    }

    boolean skipTruely(String yahoo, String BasicTrain, String logic, String f1, String f2, String f3) {
        String[] sa = new String[6];
        sa[0] = yahoo;
        sa[1] = BasicTrain;
        sa[2] = logic;
        sa[3] = f1;
        sa[4] = f2;
        sa[5] = f3;
        String join = StringUtils.join(sa, ":");
        Integer get = nn.get(join);
        if (get == null) {
            return false;
        }
        return true;
    }
}
